<?php

namespace Home\Controller;
use User\Api\UserApi;

/**
 * 用户控制器
 * 最新资讯
 */
class NewInfoController extends HomeController {

	
 public function index($p = 1)
    {
   
        $domain_id = C('SITE');
        $p = I('p',1);
        $p = intval($p);
		//标签管理
        $tags= D('Common/Tags');
       /*  if(is_file($f=HTML_PATH.'index.html') && (NOW_TIME-filemtime($f)<36000)){
            include $f;
            exit;
        } */
        //文章基础信息表
        $document =  D('Common/Document');
      	//文章分类表 ：category_tags=1
        $category =  D('Common/category');
        if($recommend){
            $recommend=getNameCount($recommend,'Document','pin_yin');
        }
       
        $lists = $document->getSiteNewArticleList($domain_id, $limit=10);
        //增加pin_yin属性的统计
        $lists=getNameCount($lists,'Document','pin_yin');
        $articleId=array_column($lists, 'id');
        $category_tag= D('Common/Tags')->getTags($articleId);//获取标签

        $categoryAll = $category->getChildrentitle(1);//获取分类


        $ad=M('AdvertiseContent');
        $footerAd=$ad->where('category_id=5')->order('sort')->find();

     

        $header_tag=array_column($category_tag, "tag_name");
        $header_tag=implode($header_tag, '.');
        //$header_nav[]=M('Tags')->order('rank desc')->limit(3)->select();
        //$header_nav[]=M('Category')->order('rank')->limit(3)->select();
        C('WEB_SITE_DESCRIPTION',C('WEB_SITE_TITLE'));
        C('WEB_SITE_KEYWORD', $header_tag);
        
        $this->header();//头部内容
        $this->assign('footerAd',$footerAd);
        
        $newDoc=$document->getSiteNewArticleList();//最新资讯
        $newDoc=getNameCount($newDoc,'Document','pin_yin');//对pin_yin属性进行统计
        
        $this->assign('newDoc',$newDoc);
        $this->assign('lists',$lists);//列表
        $this->assign('category',$categoryAll);//分类
        $this->assign('tags',$category_tag);//标签

        
       //echo  $this->buildHtml('index.html');
       $this->_display('lists');
    }
    


}
